require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
var vm = new Vue({
    el:"#myWallet",
    data:{
        loginUid:userInfo.id,
        walletInfo:{}
    },
    mounted:function(){
        this.myWalletInfo();
    },
    methods:{
        //后退
        getBack:function(){
            // history.go(-1);
            location.href="/happyi"
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //我的钱包
        myWalletInfo:function(){
            var that=this;
            var data={
                loginUid:that.loginUid
            };
            this.ajax({url:"/happyi/myWalletInfo",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.walletInfo=b.json.data;
                }else{
                    vm.$refs.prompt.toast("获取钱包信息失败！");
                }
            });

        },
        getNext:function(num){
            if(num==1){
                location.href="/happyi/walletDetailed?uid="+this.loginUid;
            }else if(num==2){
                location.href="/happyi/incomeAssets?uid="+this.loginUid;
            }else if(num==3){
                vm.$refs.prompt.toast("请前往app充值！");
                //location.href="/user/recharge?uid="+this.loginUid;
            }else if(num==4){
                vm.$refs.prompt.toast("暂未开放，敬请期待!");
            }
        }
    }
});